import userPinia from "~/pinia/user";
export default defineNuxtRouteMiddleware((to, from) => {
  const userStore = userPinia();
  const myToken = useCookie("myToken");
  if (!myToken.value && to.path === "/detail") {
    if (from.path === "/detail") {
      console.log("haha");
      navigateTo("/product");
      return;
    } else {
      userStore.setLoginDialog(true);
      return abortNavigation();
    }
  }
});
